home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
ww_tv.exe
/
TVEDIT1.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-24
|
4KB
|
188 lines
/*----------------------------------------------------------*/
/* */
/* Turbo Vision 1.0 */
/* Copyright (c) 1991 by Borland International */
/* */
/* Turbo Vision TVEDIT source file */
/*----------------------------------------------------------*/
#define Uses_TApplication
#define Uses_TEditWindow
#define Uses_TDeskTop
#define Uses_TRect
#define Uses_TEditor
#define Uses_TFileEditor
#define Uses_TFileDialog
#define Uses_TChDirDialog
#include <tv.h>
#include "tvedit.h"
#include <stdlib.h>
#include <stdarg.h>
#include <strstrea.h>
#include <iomanip.h>
TEditWindow *clipWindow;
TEditWindow *TEditorApp::openEditor( const char *fileName, Boolean visible )
{
TRect r = deskTop->getExtent();
TEditWindow *p = (TEditWindow*)validView( new TEditWindow( r, fileName, wnNoNumber ) );
//??
p->editor->wordWrap = True; // ???????????
p->editor->autosizeMargin = True; // ???????????
p->editor->retChar = '\x14'; // ??????????? paragraph symbol
if( !visible )
p->hide();
deskTop->insert( p );
return p;
}
TEditorApp::TEditorApp() :
TProgInit( TEditorApp::initStatusLine,
TEditorApp::initMenuBar,
TEditorApp::initDeskTop
),
TApplication()
{
TCommandSet ts;
ts.enableCmd( cmSave );
ts.enableCmd( cmSaveAs );
ts.enableCmd( cmCut );
ts.enableCmd( cmCopy );
ts.enableCmd( cmPaste );
ts.enableCmd( cmClear );
ts.enableCmd( cmUndo );
ts.enableCmd( cmFind );
ts.enableCmd( cmReplace );
ts.enableCmd( cmSearchAgain );
disableCommands( ts );
TEditor::editorDialog = doEditDialog;
clipWindow = openEditor( 0, False );
if( clipWindow != 0 )
{
TEditor::clipboard = clipWindow->editor;
TEditor::clipboard->canUndo = False;
}
}
void TEditorApp::fileOpen()
{
char fileName[MAXPATH];
strcpy( fileName, "*.*" );
if( execDialog( new TFileDialog( "*.*", "Open file",
"~N~ame", fdOpenButton, 100 ), fileName) != cmCancel )
openEditor( fileName, True );
}
void TEditorApp::fileNew()
{
openEditor( 0, True );
}
void TEditorApp::changeDir()
{
execDialog( new TChDirDialog( cdNormal, 0 ), 0 );
}
void TEditorApp::dosShell()
{
suspend();
system("cls");
cout << "Type EXIT to return...";
system( getenv( "COMSPEC"));
resume();
redraw();
}
void TEditorApp::showClip()
{
clipWindow->select();
clipWindow->show();
}
void TEditorApp::tile()
{
deskTop->tile( deskTop->getExtent() );
}
void TEditorApp::cascade()
{
deskTop->cascade( deskTop->getExtent() );
}
void TEditorApp::handleEvent( TEvent& event )
{
TApplication::handleEvent( event );
if( event.what != evCommand )
return;
else
switch( event.message.command )
{
case cmOpen:
fileOpen();
break;
case cmNew:
fileNew();
break;
case cmChangeDrct:
changeDir();
break;
case cmDosShell:
dosShell();
break;
case cmShowClip:
showClip();
break;
case cmTile:
tile();
break;
case cmCascade:
cascade();
break;
default:
return ;
}
clearEvent( event );
}
int main(int argc, char** argv)
{
TEditorApp editorApp;
if (argc > 1) {
TEvent event;
if (stricmp(argv[1], "Play") == 0) {
event.what = evCommand;
event.message.command = cmPlay;
editorApp.putEvent(event);
} else if (stricmp(argv[1], "Record") == 0) {
event.what = evCommand;
event.message.command = cmRecord;
editorApp.putEvent(event);
}
}
editorApp.run();
return 0;
}